package com.ahui.util;

import com.aspose.words.License;
import lombok.extern.slf4j.Slf4j;

import java.io.InputStream;

/**
 * 授权工具类
 *
 * @author zhangheng
 * @since 2021/7/9 0009 11:25
 */
@Slf4j
public class LicenseUtil {

    private static boolean licensed = false;

    /**
     * 获取license
     *
     * @return 是否
     */
    public static synchronized boolean getLicense() {
        if (licensed) {
            return true;
        }

        boolean result = false;
        try (InputStream is = LicenseUtil.class.getClassLoader().getResourceAsStream("Aspose.Total.Java.lic")) {
            License license = new License();
            license.setLicense(is);
            result = true;
            licensed = true;
        } catch (Exception e) {
            log.error("----------读取license.xml出错----------", e);
        }
        return result;
    }
}
